package com.example.demo.controller;

import com.example.demo.config.ConfigTestBean;
import com.example.demo.config.ConfigTestBean2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 张露晨
 * @date 2017/9/27 10:08.
 */
@RestController
@RequestMapping("/config")
public class ConfigController {

    @Autowired
    private ConfigTestBean configTestBean;

    @Autowired
    private ConfigTestBean2 configTestBean1;

    @Value("${name}")
    private String name;

    @Value("${want}")
    private String want;

    @Value("${todo}")
    private String todo;

    @GetMapping("test")
    public String test() {
        return "name:" + configTestBean.getName() + "\nwant:" + configTestBean.getWant() + "\ntodo:" + configTestBean.getTodo();
    }

    @PostMapping("test1")
    public String test1() {
        return "name:" + configTestBean1.getName() + "\nwant:" + configTestBean1.getWant() + "\ntodo:" + configTestBean1.getTodo();
    }

    @PostMapping("test2")
    public String test2() {
        return "name:" + name + "\nwant:" + want + "\ntodo:" + todo;
    }


}
